package com.hxc.web.controller.basicdata;

import java.util.List;

import io.swagger.annotations.Api;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hxc.common.annotation.Log;
import com.hxc.common.core.controller.BaseController;
import com.hxc.common.core.domain.AjaxResult;
import com.hxc.common.enums.BusinessType;
import com.hxc.basicdata.domain.TGroupInfo;
import com.hxc.basicdata.service.ITGroupInfoService;
import com.hxc.common.utils.poi.ExcelUtil;
import com.hxc.common.core.page.TableDataInfo;


/**
 * 组别信息Controller
 * 
 * @author hxc
 * @date 2021-08-11
 */
@Api(tags = "村组别信息")
@RestController
@RequestMapping("/basicdata/group")
public class TGroupInfoController extends BaseController
{
    @Autowired
    private ITGroupInfoService tGroupInfoService;

    /**
     * 查询组别信息列表
     */
    @PreAuthorize("@ss.hasPermi('basicdata:group:list')")
    @GetMapping("/list")
    public TableDataInfo list(TGroupInfo tGroupInfo)
    {
        startPage();
        List<TGroupInfo> list = tGroupInfoService.selectTGroupInfoList(tGroupInfo);
        return getDataTable(list);
    }

    /**
     * 查询组别信息列表(不分页)
     */
    @PreAuthorize("@ss.hasPermi('basicdata:group:list')")
    @GetMapping("/groupList")
    public AjaxResult groupList(TGroupInfo tGroupInfo)
    {
        List<TGroupInfo> list = tGroupInfoService.selectTGroupInfoList(tGroupInfo);
        return AjaxResult.success("success", list);
    }

    /**
     * 导出组别信息列表
     */
    @PreAuthorize("@ss.hasPermi('basicdata:group:export')")
    @Log(title = "组别信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TGroupInfo tGroupInfo)
    {
        List<TGroupInfo> list = tGroupInfoService.selectTGroupInfoList(tGroupInfo);
        ExcelUtil<TGroupInfo> util = new ExcelUtil<TGroupInfo>(TGroupInfo.class);
        return util.exportExcel(list, "组别信息数据");
    }

    /**
     * 获取组别信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('basicdata:group:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tGroupInfoService.selectTGroupInfoById(id));
    }

    /**
     * 新增组别信息
     */
    @PreAuthorize("@ss.hasPermi('basicdata:group:add')")
    @Log(title = "组别信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TGroupInfo tGroupInfo)
    {
        return toAjax(tGroupInfoService.insertTGroupInfo(tGroupInfo));
    }

    /**
     * 修改组别信息
     */
    @PreAuthorize("@ss.hasPermi('basicdata:group:edit')")
    @Log(title = "组别信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TGroupInfo tGroupInfo)
    {
        return toAjax(tGroupInfoService.updateTGroupInfo(tGroupInfo));
    }

    /**
     * 删除组别信息
     */
    @PreAuthorize("@ss.hasPermi('basicdata:group:remove')")
    @Log(title = "组别信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tGroupInfoService.deleteTGroupInfoByIds(ids));
    }
}
